From 7198d1372501b02f1c495fdcd72644168031eafa Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 15 Feb 2010 02:57:00 +0000 Subject: [PATCH] Finish hooking up all the UI for preferences. --- gui/babeldata.h | 13 ++++++++++--- gui/format.h | 4 +++- gui/mainwindow.cpp | 14 ++++++++------ gui/preferences.cpp | 21 +++++++++++++++------ gui/preferences.h | 5 ++++- gui/preferences.ui | 28 +++++++++++----------------- gui/setting.h | 3 ++- gui/upgrade.cpp | 7 ++++--- gui/upgrade.h | 3 ++- 9 files changed, 59 insertions(+), 39 deletions(-) diff --git a/gui/babeldata.h b/gui/babeldata.h index 540e729fb..5f87fb5a4 100644 --- a/gui/babeldata.h +++ b/gui/babeldata.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: babeldata.h,v 1.4 2010/02/14 05:33:36 robertl Exp $ +// $Id: babeldata.h,v 1.5 2010/02/15 02:57:00 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -57,7 +57,8 @@ public: upgradeCheckMethod(0), upgradeCheckTime(QDateTime(QDate(2001, 1, 1), QTime(0, 0))), installationUuid(QUuid::createUuid().toString()), - checkUpgradeOnStart(true) + startupVersionCheck(true), + reportStatistics(true) { }; @@ -100,6 +101,11 @@ public: sg.addVarSetting(new IntSetting("app.upgradeCheckMethod", upgradeCheckMethod)); sg.addVarSetting(new DateTimeSetting("app.upgradeCheckTime", upgradeCheckTime)); sg.addVarSetting(new StringSetting("app.installationUuid", installationUuid)); + + // Global preferences. + sg.addVarSetting(new BoolSetting("app.startupVersionCheck", startupVersionCheck)); + sg.addVarSetting(new BoolSetting("app.reportStatistics", reportStatistics)); + } static const int noType; @@ -137,7 +143,8 @@ public: QString installationUuid; // Global preferences. - bool checkUpgradeOnStart; + bool startupVersionCheck; + bool reportStatistics; }; diff --git a/gui/format.h b/gui/format.h index b78b15215..e83d2682c 100644 --- a/gui/format.h +++ b/gui/format.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: format.h,v 1.5 2010/02/14 05:33:37 robertl Exp $ +// $Id: format.h,v 1.6 2010/02/15 02:57:00 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -185,7 +185,9 @@ class Format bool isDeviceFormat() const { return deviceFormat; }; bool isFileFormat() const { return fileFormat; }; + bool isHidden() const { return hidden_; }; + void setHidden(bool state) { hidden_ = state; }; void saveSettings(QSettings &settings); void restoreSettings(QSettings &settings); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index dc8d0a9b7..42b5a8836 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: mainwindow.cpp,v 1.15 2010/02/14 21:29:06 robertl Exp $ +// $Id: mainwindow.cpp,v 1.16 2010/02/15 02:57:00 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -172,10 +172,11 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent) //--- Restore from registry restoreSettings(); - if (bd.checkUpgradeOnStart) { + if (bd.startupVersionCheck) { upgrade = new UpgradeCheck(parent, formatList); upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod, - bd.upgradeCheckTime, bd.installationUuid); + bd.upgradeCheckTime, bd.installationUuid, + bd.reportStatistics); } } @@ -252,7 +253,6 @@ void MainWindow::inputFileOptBtnClicked() ui.inputFormatCombo->clear(); for (int i=0; iaddItem(formatList[k].getDescription(), QVariant(k)); } @@ -270,7 +270,6 @@ void MainWindow::inputDeviceOptBtnClicked() ui.inputFormatCombo->clear(); for (int i=0; iaddItem(formatList[k].getDescription(), QVariant(k)); } @@ -965,8 +964,11 @@ void MainWindow::aboutActionX() //------------------------------------------------------------------------ void MainWindow::preferencesActionX() { - Preferences preferences(0, formatList); + Preferences preferences(0, formatList, bd); preferences.exec(); + + // We may have changed the list of displayed formats. Resynchronize. + setWidgetValues(); } diff --git a/gui/preferences.cpp b/gui/preferences.cpp index a5307ba8e..3d01dfd3c 100644 --- a/gui/preferences.cpp +++ b/gui/preferences.cpp @@ -17,7 +17,6 @@ // USA -#include #include "preferences.h" class FormatListEntry : public QListWidgetItem { @@ -32,13 +31,16 @@ class FormatListEntry : public QListWidgetItem { Format& fmt_; }; -Preferences::Preferences(QWidget* parent, QList& formatList) : - formatList_(formatList) +Preferences::Preferences(QWidget* parent, QList& formatList, + BabelData& bd) : QDialog(parent), + formatList_(formatList), + bd_(bd) { ui_.setupUi(this); - // TODO: read from prefs. - // ui_.startupCheck->setChecked(true); + ui_.startupCheck->setChecked(bd_.startupVersionCheck); + ui_.reportStatisticsCheck->setChecked(bd_.reportStatistics); + connect (ui_.buttonBox, SIGNAL(accepted()), this, SLOT(acceptClicked())); connect (ui_.buttonBox, SIGNAL(rejected()), this, SLOT(rejectClicked())); @@ -48,7 +50,7 @@ Preferences::Preferences(QWidget* parent, QList& formatList) : for (int i = 0; i < formatList_.size(); i++) { FormatListEntry *item = new FormatListEntry(formatList[i]); - ui_.enabledFormatsList->insertItem(0, item); + ui_.enabledFormatsList->addItem(item); } } @@ -70,6 +72,13 @@ void Preferences::disableAllClicked() void Preferences::acceptClicked() { + for (int i = 0; i < ui_.enabledFormatsList->count(); i++) { + QListWidgetItem* item = ui_.enabledFormatsList->item(i); + formatList_[i].setHidden(item->checkState() == Qt::Unchecked); + } + + bd_.startupVersionCheck = ui_.startupCheck->isChecked(); + bd_.reportStatistics = ui_.reportStatisticsCheck->isChecked(); accept(); } diff --git a/gui/preferences.h b/gui/preferences.h index 15c95aa7e..d934752c7 100644 --- a/gui/preferences.h +++ b/gui/preferences.h @@ -20,17 +20,20 @@ // USA #include "ui_preferences.h" + +#include "babeldata.h" #include "format.h" class Preferences : public QDialog { Q_OBJECT public: - Preferences(QWidget* parent, QList& formatList); + Preferences(QWidget* parent, QList& formatList, BabelData& bd); private: QList& formatList_; Ui_Preferences ui_; + BabelData& bd_; private slots: void enableAllClicked(); diff --git a/gui/preferences.ui b/gui/preferences.ui index 6ed33529e..6b44e9083 100644 --- a/gui/preferences.ui +++ b/gui/preferences.ui @@ -6,12 +6,12 @@ 0 0 - 777 - 351 + 554 + 404 - + 0 0 @@ -22,12 +22,6 @@ - - - 0 - 0 - - 1 @@ -50,19 +44,13 @@ Check for newer version on start. - - true - - + Anonymously report usage data. - - true - @@ -84,8 +72,14 @@ + + + 0 + 0 + + - true + false diff --git a/gui/setting.h b/gui/setting.h index a0902cda1..2003c9e30 100644 --- a/gui/setting.h +++ b/gui/setting.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: setting.h,v 1.2 2009/09/02 19:05:27 robertl Exp $ +// $Id: setting.h,v 1.3 2010/02/15 02:57:00 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -24,6 +24,7 @@ #define SETTING_H #include +#include //------------------------------------------------------------------------ diff --git a/gui/upgrade.cpp b/gui/upgrade.cpp index 22613fd4d..b88a81e90 100644 --- a/gui/upgrade.cpp +++ b/gui/upgrade.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: upgrade.cpp,v 1.21 2010/02/14 21:29:06 robertl Exp $ +// $Id: upgrade.cpp,v 1.22 2010/02/15 02:57:00 robertl Exp $ /* Copyright (C) 2009, 2010 Robert Lipe, robertlipe@gpsbabel.org @@ -115,7 +115,8 @@ QString UpgradeCheck::getOsVersion() UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString ¤tVersionIn, int checkMethod, const QDateTime &lastCheckTime, - const QString &installationUuid) + const QString &installationUuid, + bool reportStatistics) { currentVersion = currentVersionIn; currentVersion.remove("GPSBabel Version "); @@ -168,7 +169,7 @@ UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString ¤tV if (wc) args += QString("&uc%1=wr/%2/%3").arg(j++).arg(formatName).arg(wc); } - if (j) + if (j && reportStatistics) args += QString("&uc=%1").arg(j); if (false && testing) diff --git a/gui/upgrade.h b/gui/upgrade.h index 523e75615..32623317d 100644 --- a/gui/upgrade.h +++ b/gui/upgrade.h @@ -43,7 +43,8 @@ public: UpgradeCheck::updateStatus checkForUpgrade(const QString &babelVersion, int upgradeCheckMethod, const QDateTime &lastCheckTime, - const QString &installationUuid + const QString &installationUuid, + bool reportStatistics ); QDateTime getUpgradeWarningTime() { return upgradeWarningTime; -- 2.30.2